home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
MSC2BC.ARJ
/
FARHEAP.TXT
< prev
next >
Wrap
Text File
|
1992-06-26
|
3KB
|
49 lines
The following notes, keyed to comments in each program, explain
the differences:
Note 1 - You can make short work out of converting programs that
use Microsoft C far heap management by #defining functions,
structures, and variables that are the same or similar in Borland
C++.
Note 2 - You need to add an array to maintain information about
the current size of each heap block.
Note 3 - You need to calculate and save the size of each heap
block before it is allocated with Borland C++.
Note 4 - Borland C++ does not allow you to allocate a heap block
that is zero bytes in size. If there is any chance that your
program can calculate a required heap block size of zero bytes,
you should check for that possibility prior to allocating the
block.
Note 5 - Borland C++ far heap management is more robust than
Microsoft's, because it concatenates adjacent free heap blocks
together to form a single larger heap block, and it reuses heap
blocks that were freed earlier.
Note 6 - The Borland C++ farheapinfo structure is slightly
different than the Microsoft C _heapinfo structure. The size of
the heap block reported back by Microsoft _fheapwalk function is
exactly the amount requested by your program. The Borland C++
farheapwalk function reports the size of the entire structure
managed by the memory manager. This includes the amount of memory
accessible to your program, the control structure used by the
memory manager itself, and any bytes necessary to pad the entire
heap structure to an exact multiple of 16 bytes.
Note 7 - The Microsoft C _fheapwalk function allows you to
examine and change free heap blocks, memory which does not
legitimately belong to your program. The Borland C++ farheapwalk
function hides free heap blocks from you. With Borland C++, to
check that the free far heap block is not corrupted, use the
farheapcheckfree function.
Note 8 - In providing you with information about the state of the
heap, Microsoft C defines three manifest constants for error
conditions which are not defined by Borland C++. Each of them
indicates a different type of corruption of the heap, and other
than reporting this fact, there is little else that you can do in
your program.